package pers.cocoadel.springcloud.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pers.cocoadel.springcloud.dao.PaymentDao;
import pers.cocoadel.springcloud.entities.Payment;
import pers.cocoadel.springcloud.service.PaymentService;

/**
 * @author rwby
 */
@Service
public class PaymentServiceImpl implements PaymentService
{

    private final PaymentDao paymentDao;

    @Autowired(required = false)
    public PaymentServiceImpl(PaymentDao paymentDao)
    {
        this.paymentDao = paymentDao;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int create(Payment payment)
    {
        return paymentDao.create(payment);
    }

    @Transactional(readOnly = true)
    @Override
    public Payment getById(Long id)
    {
        return paymentDao.getById(id);
    }
}
